package cn.tsoft.taobao.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.widget.Button;
import android.widget.LinearLayout;
import cn.tsoft.taobao.logic.ITaoBaoActivity;
import cn.tsoft.taobao.logic.Task;
import cn.tsoft.taobao.logic.TaskManagerActivity;
import cn.tsoft.taobao.misc.BounceInterpolator;
import cn.tsoft.taobao.misc.EasingType.Type;

public class HomeActivity extends TaskManagerActivity  implements ITaoBaoActivity{

	 private Animation animLeft, animRight;
	 
	 private Interpolator interpolator;
	 
	 private LinearLayout twitterRow, messageRow ;
	
	@Override
	public void init() {

	}

	@Override
	public void refresh(Object... param) {

	}
	
    //返回按钮
    private Button  returnButton = null;
    //登录按钮
    private Button  loginButton  = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
	    	setContentView(R.layout.home);
	    	View titleBar  = (View) findViewById(R.id.titleBar);
	 	    returnButton = (Button)titleBar.findViewById(R.id.return_button);
	 	    loginButton = (Button)titleBar.findViewById(R.id.login_button);
	 	    
	 	    animLeft = AnimationUtils.loadAnimation(this, R.anim.slide_in_left);
	        animRight = AnimationUtils.loadAnimation(this, R.anim.slide_in_right);
	        interpolator =new  BounceInterpolator(Type.IN);
	        animLeft.setInterpolator(interpolator);
	        animRight.setInterpolator(interpolator);
	 	    
	 	   setupView();
	 	   
	 	  twitterRow = (LinearLayout)findViewById(R.id.twitter_row);
	      twitterRow.setOnClickListener(new View.OnClickListener() {
	        	Task task = null;
	        	Intent intent ;
	            @SuppressWarnings("static-access")
				public void onClick(View v) {
					 task=new Task(Task.TRADE_ORDER_ITEM,null);
					 getStuffApplication().addTask(task);
					 intent = new Intent(HomeActivity.this,TradeOrder.class);
					 startActivity(intent);
	            }
	        });
	      
	      twitterRow.startAnimation(animRight);
	        
//	   	 task=new Task(Task.ONSALE_PRODUCT_ITEM,null);
//		 getStuffApplication().addTask(task);
//		 intent = new Intent(HomeActivity.this,ProductItem.class);
//		 startActivity(intent);
	        
	}

	
	private void setupView() {
		returnButton.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				
			}
		});
		
		loginButton.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Intent intent =new Intent(HomeActivity.this,LoginActivity.class);
				startActivity(intent);
			}
		});
		
	}
	
}
